package com.yfl.logistics.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yfl.logistics.pojo.Permission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ${author}
 * @since 2020-06-13
 */
@Repository
public interface PermissionMapper extends BaseMapper<Permission> {

    //自定义查询权限表
    @Select("SELECT c.*,p.`name` pname from t_permission c LEFT JOIN t_permission p on c.parent_id=p.permission_id ${ew.customSqlSegment}")
    IPage<Permission> selectPermission(IPage iPage, @Param(Constants.WRAPPER) QueryWrapper wrapper);

    @Select("SELECT expression from t_permission where permission_id in(${permissionIds})")
    List<String> selectRoleExpression(String permissionIds);
}
